import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig({
  plugins: [vue()],
  css: {
    // preprocessorOptions: {
    //   scss: {
    //     additionalData: `@use "@/assets/style/style.scss" as *;`
    //   }
    // }
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  server: {
    host: '0.0.0.0',
    proxy: {
      // 匹配以 /api 开头的请求
      '/api': {
        target: 'http://localhost:3000', // 目标地址
        changeOrigin: true,               // 是否修改 Origin 为目标地址
        rewrite: path => path.replace(/^\/api/, '/api/a') // 去除请求路径中的 /api 前缀
      }
    }
  }
})
